package com.example.demo.service;


import com.example.demo.mapper.DashboardMapper;
import com.example.demo.model.DashboardInfo;

import com.example.demo.model.Result;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class DashboardService {
    DashboardMapper dashboardMapper;
    DashboardInfo dashboardInfo;
    public Result getShowInfo(){
        //获取今日的销售额
        dashboardInfo.setSalesToday(dashboardMapper.getTotalSalesToday());
        //获取今日新增用户数量
        dashboardInfo.setAddUserToday(dashboardMapper.getAddUserToday());
        //获取近一周新增用户数量
        dashboardInfo.setAddUserWeek(dashboardMapper.getAddUserWeek());
        //获取近30天新增用户数量
        dashboardInfo.setAddUserMonth(dashboardMapper.getAddUserMonth());
        //获取销售量前十的热门商品
        dashboardInfo.setHotProduct(dashboardMapper.getHotProduct());

        return Result.buildSuccess(dashboardInfo);
    }
    public Result getEveryWeekAdd(){
        return Result.buildSuccess(dashboardMapper.selectEveryWeekAdd());
    };

    public Result getEveryMonthAdd(){
        return Result.buildSuccess(dashboardMapper.selectEveryMonthAdd());
    };

    public Result getEveryWeekTotalSales(){
        return Result.buildSuccess(dashboardMapper.selectEveryWeekTotalSales());
    };
}
